#include "mystdio.h"
#include <string.h>
#include <unistd.h>
const char* filename = "./Date.txt";

int main()
{
    myfile* fp = myfopen(filename,"w");
    if(fp == NULL) return -1;
    int cnt = 5;
    char buffer[64];
    while(cnt)
    {
        snprintf(buffer,sizeof(buffer),"helloworld,helle bit %d\n",cnt);
        myfwrite(fp,buffer,strlen(buffer));
        debugPrintf(fp);
        sleep(1);
        cnt--;
    }
        
    myfclose(fp);



    /*
    if(fp == NULL)
    {
        return 1;
    }
    
    const char* s1 = "hello myself stdio interfacea\n";
    myfwrite(fp,s1,strlen(s1));

    myfclose(fp);
    
    //printf("hello world\n");
    */
    return 0;
}


/*
#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main()
{
    //使用system
    const char * s1 = "hello write\n";
    write(1,s1,strlen(s1));    

    //使用c语言接口
    const char* s2 = "hello fprintf\n";
    fprintf(stdout,"%s",s2);

    const char* s3 = "hello fwrite\n";
    fwrite(s3,strlen(s3),1,stdout);
    fork();
    return 0;
}
*/

